package com.lone.demo.singleton;

public class SingletonTest01 {
    public static void main(String[] args) {
        Singleton instance1 = Singleton.getInstance();
        Singleton instance2 = Singleton.getInstance();
        System.out.println(instance1 == instance2);
    }
}

// 饿汉式
class Singleton {

    private static Singleton instance = new Singleton();
    // 1. 构造器私有化
    private Singleton() {
    }

    public static Singleton getInstance() {
        return instance;
    }
}
